﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>学生信息维护</title>

    <script language="JavaScript" src="/WF/Comm/JScript.js" type="text/javascript" ></script>
    <script type="text/javascript" src="/WF/Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="/WF/Scripts/QueryString.js" type="text/javascript"></script>
    <link href="/DataUser/Style/ccbpm.css" rel="stylesheet"  type="text/css" />

    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="/WF/Scripts/config.js"></script>
    <script type="text/javascript" src="/WF/Comm/Gener.js"></script>

    <script type="text/javascript" language="javascript" >
        //页面启动函数.
        $(function () {

            $("#Msg").html("正在加载,请稍后......");

            //初始化groupID.
            var no = GetQueryString("No");

            /*
            *  首先要把初始化控件的代码写入到这里,不然会导致界面的批量赋值失败.
            */
            //调用公共类库的方法:  绑定枚举, 性别.
            GenerBindEnumKey("DDL_XB", "XB");

            //调用公共类库的方法: 绑定外键表. 班级.
            GenerBindEntities("DDL_FK_BanJi", "BP.Demo.BPFramework.BanJis");

            //创建实体.
            var en = new Entity("BP.Demo.BPFramework.Student");

            if (no != null) {
                en.SetPKVal(no);
                en.No = no;
                en.RetrieveFromDBSources();
            }


            //调用公共类库的方法:执行批量主表赋值.
            GenerFullAllCtrlsVal(en);



            $("#Msg").html("");
        });
    </script>
</head>
<body  >

<form id="cc">
<table style="width:80%;">
<caption>学生信息卡片维护</caption>
<tr>
<td > 学号</td>
<td> <input type="text" id="TB_No" /> </td>
<td> 姓名</td>
<td> <input type="text" id="TB_Name" name="TB_Name" /> </td>
</tr>

<tr>
<td>性别</td>

<td> <select name="DDL_XB" id="DDL_XB" ></select> </td>

<td> 整治面貌</td>
<td>

<!--  必须使用 RB_ 枚举值命名. -->

<input id="RB_ZZMM_0" type="radio" name="RB_ZZMM" value="0"  /><label for="RB_ZZMM_0">少先队员</label>
<input id="RB_ZZMM_1" type="radio" name="RB_ZZMM" value="1"  /><label for="RB_ZZMM_1">团员</label>
<input id="RB_ZZMM_2" type="radio" name="RB_ZZMM" value="2"  /><label for="RB_ZZMM_2">党员</label>

</td>
</tr>


<tr>
<td class="style1"> 电话</td>
<td><input type="text" id="TB_Tel" name="TB_Tel" /> </td>
<td> 邮件</td>
<td> <input type="text" id="TB_Email" name="TB_Email" /></td>
</tr>


<tr>
<td class="style1"> 地址</td>
<td colspan="3" ><input type="text" id="TB_Addr" name="TB_Addr" /> </td>
</tr>


<tr>
<td>所在班级</td>
<td colspan=3>
<select name="DDL_FK_BanJi" id="DDL_FK_BanJi" > 
</select> 
 </td>
 </tr>

<tr>
<td > <input type="checkbox" value="" id="CB_IsDuShengZi" name="CB_IsDuShengZi" /><label for="CB_IsDuShengZi">是否是独生子？</label></td>
<td > <input type="checkbox" value="" id="CB_IsJiBing" name="CB_IsJiBing" /><label for="CB_IsJiBing">是否有重大疾病？</label></td>
<td > <input type="checkbox" value="" id="CB_IsPianYuanShanQu" name="CB_IsPianYuanShanQu" /><label for="CB_IsPianYuanShanQu">是否偏远山区？</label></td>
<td > <input type="checkbox" value="" id="CB_IsTeKunSheng" name="CB_IsTeKunSheng" /><label for="CB_IsTeKunSheng">是否是特困生？</label></td>
</tr>

<tr>
<td colspan="4">
<input type="button" value="新建" onclick="New()" id="Btn_New" />
<input type="button" value="保存" onclick="Save()" id="Btn_Save" />
<input type="button" value="保存并关闭" onclick="Save()" id="Btn_SaveAndClose" />
<input type="button" value="保存并新建" onclick="SaveAndNew()" id="Btn_SaveAndNew" />
<input type="button" value="关闭" onclick="Save()" id="Btn_Close" />
<input type="button" value="删除" onclick="Delete()" id="Btn_Delete" />

<div id="Msg"> </div>


<script type="text/javascript">

    function SaveAndNew() {
        this.Save();
        this.New();
    }

    function New() {
        window.location.href = 'Student.htm';
    }

    function Save() {

        $("#Msg").html("正在保存,请稍后......");

        var no = GetQueryString("No");

        var en = new Entity("BP.Demo.BPFramework.Student");
        if (no != null) {
            en.SetPKVal(no);
            en.RetrieveFromDBSources();
        }

        en.CopyForm(); //把数据copy到实体里.

        if (no == null) {
            no = $("#TB_No").val();
        }

        en.SetPKVal(no);
        en.Save();
         

        window.location.href = 'Student.htm?No=' + en.No;

    }
    function SaveAndClose() {
        this.Save();
        window.close();
    }
    function Close() {
        window.close();
    }

    function Delete() {

        var name = $("#TB_Name").val();
        if (window.confirm('您确定要删除[' + name + ']吗？') == false)
            return false;
        var no = $("#TB_No").val();

        var en = new Entity("BP.Demo.BPFramework.Student", no);
        en.Delete();

        alert("delete ok.");
        window.location.href = 'Student.htm';

    }
</script>

</td>
</tr>
</table>



<fieldset>
<legend>开发约定与说明</legend>

<ul>
    
<li>需要对 /WF/Comm/Gener.js  进行引用.</li>
<li>控件的命名必须以 TB_ , DDL_, CB, RB_ 开头, 后半部分，必须与实体类的字段名称保持一致。</li>
<li>按钮必须以 Btn_ 开头, 常用的按钮名称需要保持一致，比如： Btn_Save  Btn_SaveAndClose , Btn_Close , Btn_Delete </li>
<li>常用的函数名必须保持一致，比如： Save()  SaveAncClose() Delete() Close() ...</li>
<li>每个控件的name 的值，都不能为空，否则会导致数据传递不过去，并且checkbox的ids 取不出来。</li>
<li>该界面是一个jq与bp框架的entity结合的实体信息存储，适用方面广，设计与实现比较容易，籍希望各位同事按照这个模式进行开发。</li>

</ul>

</fieldset> 

</form>

</body>
</html>
